package cn.achuan.spring.springcloud.demo;

import cn.achuan.spring.springcloud.demo.product.Product;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

// @FeignClient注解中增加了fallback的配置，并设置其值为ProductServiceFallback。
@FeignClient(name = "PRODUCT-SERVICE", fallback = ProductServiceFallback.class)
//@FeignClient("PRODUCT-SERVICE")
public interface ProductService {

    @RequestMapping(value = "/products", method = RequestMethod.GET)
    List<Product> findAll();

    @RequestMapping(value = "/products/{itemCode}", method = RequestMethod.GET)
    Product loadByItemCode(@PathVariable("itemCode") String itemCode);

}